/*
 * customer.h
 *
 *  Created on: May 30, 2011
 *      Author: peskanda
 */

#ifndef CUSTOMER_H_
#define CUSTOMER_H_
#include "synch.h"
#include "sharedDefinitions.h"
#include "homedepot.h"
#include "locks.h"



class Customers {
private:
	int _customerID;
	bool _wantsToReturnItems;
	Store* _store;
	Locks* _allTheLocks;
	int* _shoppingList;
	int _shoppingListSize;
public:
    Customers(int customerID,bool wantsToReturnItems, Store* store,Locks* allTheLocks);
    ~Customers();
    /*
	 * Main function for customer which organized his/her activities
	 */
	void DoShopping();
    /*
     *
     */
    void CollectShoppingListItems();
    /*
     * Returns the aisle number for a given item ID
     * 75% of the times customer can immediately know the aisle id, but
     * 25% of the times he needs to ask this from a stockboy
     */
    int LookForAisleNumber(int itemId);
    /*
     * Given a specific item id, this function will put a request on re stocking
     * specific item.
     */
    bool PickupItem(int aisleNumber, int itemId);
    /*
     * Finds the shortest line and gets into it; if no clerk in duty will wait for
     * manager to signal a clerk and eventually will get into a line.
     * The customer will wait till its his/her turn (signal receive from clerk).
     * Once he is woken up he will lock the clerk.
     * At the end of this function we are guaranteed that the clerk is locked and ready to service to us.
     */
    int GetIntoTheShortestClerkLine();
    int LookForShortestClerkLine();
    /*
     * Provides all of the items to clerk. Clerk is already locked and
     * Waiting for us. At the end of this function we still have the clerk locked
     * but havn't released the clerk lock yet. As a result, clerk is still
     * sleeping waiting for so we declare we are ready for totals
     */
    void ProvideTheItemsToClerk(int clerkID);
    /*
     * This function first will query the total amount of transaction
     * (either the amount due, or the total refund amount), pay/receives the
     * payments, and takes the receipt. The clerk will be remained locked
     * the whole time in this function.
     */
    void TransferPayment(int clerkID);
    /*
     * Leaving the store
     */
    void LeaveStore();
};
#endif /* CUSTOMER_H_ */
